package com.shuoyue.ycgk.ui.papergroups.running;

import com.shuoyue.ycgk.base.BaseModel;
import com.shuoyue.ycgk.base.BasePresenter;
import com.shuoyue.ycgk.base.BaseResult;
import com.shuoyue.ycgk.base.BaseView;
import com.shuoyue.ycgk.base.ListWithPage;
import com.shuoyue.ycgk.entity.Paper;
import com.shuoyue.ycgk.entity.PaperSet;
import com.shuoyue.ycgk.net.RetrofitClient;
import com.shuoyue.ycgk.net.base.ApiSubscriber;
import com.shuoyue.ycgk.net.gsondefaultadapter.Optional;

import java.util.List;

import io.reactivex.Observable;

public interface RushContract {
    interface View extends BaseView {

        void setPaperSetInfo(PaperSet paperInfo);
    }

    class Presenter extends BasePresenter<View> {
        Model model = new Model();




        public void getRushInfo(int modelId) {
            apply(model.getRushInfo(modelId))
                    .subscribe(new ApiSubscriber<Optional<PaperSet>>(mView, this) {
                        @Override
                        public void onNext(Optional<PaperSet> listOptional) {
                            super.onNext(listOptional);
                            mView.setPaperSetInfo(listOptional.getIncludeNull());
                        }
                    });
        }


    }

    class Model extends BaseModel {

        /**
         * @param moduleId
         * @return
         */
        Observable<BaseResult<PaperSet>> getRushInfo(int moduleId) {
            return RetrofitClient.getInstance().getApi().getRushInfo(moduleId);
        }

    }
}
